HSIM

Simulator for Amateur Hybrid Rocket Motors

Version 0.2

Stephen Daniel
Evan Daniel

September 4, 2006

Introduction

Hsim is intended as a physically and mathematically precise simulator for simple hybrid rocket motors that use self-pressurized liquid N2O as an oxidizer and one of a small set of solids as the fuel.

The input is text file that describes the simulation.

The output is a text file that can be post-processed into a summary report or into an engine data file for Rocksim version 8.

At present the models assume the tank is a cylinder and that the fuel grain is a cylinder (i.e. has a single port). The assumption of self-pressurized nitrous is pretty baked into the model, but the other simplifying assumptions are lightly used and could probably be changed without much difficulty.

This pre-release version of the simulator is intended for use by people who have substantial knowledge of small hybrid motor design.

As-Is Usage

This simulator has been somewhat tested and appears to give reasonable results over a useful range of inputs. However, the authors make no warranty of correctness or even reasonableness.

Use of a simulator does not substitute for proper testing of a motor design.

Warranty

BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.

IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.

Licensing

Hsim and related components are distributed in source form under a GPL license. The full text of the license can be viewed by running hsim -l

Revision History

September 4, 2006: Hsim 0.2

  • First version published on the web.
  • Substantial cleanup in error message handling and cpropep linkage.
  • Flight tank model now also handles tanks with a pressure relief valve rather than a simple vent.

July 1, 2006: Hsim 0.1

  • First working version. Very limited distribution.

Theory of Operation

Hsim simulates the operation of a self-pressurized nitrous hybrid using straightforward numerical techniques.

Each time-step involves these steps:

  1. Using the known mass and internal enthalpy of the nitrous in the tank compute:
    • The fraction of nitrous that is liquid and the fraction that is gaseous.
    • The temperature of the nitrous in the tank
    • The pressure of the nitrous tank

  2. Using the nitrous tank state and the fuel-grain mass compute:
    • Fuel grain geometry (current port size)
    • The nitrous flow rate
    • Fuel burn rate
    • Chamber pressure
    • Thrust

  3. Advance to the next time step:
    • Reduce the nitrous mass by the amount vented and the amount injected.
    • Reduce the nitrous enthalpy by the energy of the lost nitrous and the energy required to force that nitrous from the tank.
    • Reduce the fuel mass by the amount burned.

The Nitrous Tank Model

The tank model is built using thermodynamic data from the U.S National Institute of Standards. The model assumes that the nitrous tank is always in equilibrium. Essentially, the model believes that the temperature of nitrous does not vary throughout the tank and that the liquid and gas phases are in thermodynamic equilibrium, a condition known as saturation.

The model has available a summary of the NIST data that covers the properties of saturated nitrous from 250o K to 310o K (approximately -10o F to 98o F). Any attempt to operate the nitrous tank outside this temperature data will cause the simulator to abort.

The initial conditions inside the tank can be set one of two ways. The simulation control file may either specify an initial flight-tank pressure, or the temperature of the supply tank and the estimated pressure drop may be supplied.

The tank is assumed to be vented through a small vent, as is standard for most amateur hybrid motors. The vent model is based on Suttons formulas for cold-gas thrusters.

The tank model solves for equilibrium temperature and pressure using a simple iterative technique. The ratio of liquid to gaseous nitrous is computed for the known mass and volume at the current temperature.  The total enthalpy of the nitrous is computed.  If the calculated enthalpy does not match the known enthalpy of the nitrous the temperature is adjusted.  This calculation is repeated until the tank state converges.

The Combustion Chamber Model

The combustion chamber model is built using simple physical models of the combustion chamber and the nozzle, augmented by propellant chemistry data computed by CPROPEP.  The calculation is iterative, adjusting the chamber pressure up or down until the chamber comes into equilibrium.

The iteration loop involves these steps:

  1. Compute the nitrous flow rate through the injector.  This is a function of the known tank pressure and the presumed chamber pressure.
  2. Using a fuel regression model taken from Todd Moore’s HDAS simulator, compute the rate at which fuel burns.
  3. Using CPROPEP, compute the chamber pressure, C*, and nozzle behavior.
  4. If the computed chamber pressure does not match the presumed chamber pressure, adjust the chamber pressure and iterate.

The combustion chamber model contains two fudge-factors to account for less-than-ideal behavior.  The first is a C* adjustment.  The C* returned by CPROPEP is adjusted downward by a multiplicative factor to account for combustion inefficiencies.  Such inefficiencies are caused by incomplete combustion, possibly due to poor chamber or injector design.

In addition, the simulator adjusts the nozzle Cf by a formula that brings the Cf closer to 1.0 by a fraction.  This fraction attempts to account for imperfections in the nozzle due to poor shape.

Time Step and Error Control

Hsim has an extremely simple time-step mechanism.  The models assume that all flows (nitrous vent, nitrous injector, and fuel regression) are constant during the time step.  Time steps are fixed at a user-specified period.  All testing has been with a 1 millisecond time step.  Obviously far more sophisticated means exist for high-performance numerical integration.  Such methods can also estimate and bound errors.  However, experience has shown the simulator as written is fast enough.  The curves are all smooth enough that we believe error control is not a serious issue.  Systematic errors in the physical models are presumed to dominate over numerical errors by an order of magnitude or more.

Effects Not Modeled

Hsim’s models do not account for a number of physical effects.  At a minimum, these include:

  • Ignition: The simulator assumes that the entire fuel grain lights instantly and that any ignition grain does not contribute to chamber pressure.
  • Gas-phase burn-out.  The simulation stops when the tank runs out of liquid nitrous.
  • Tank head pressure.  The tank model does not account for additional pressure at the bottom of the tank generated by the rocket’s upward acceleration.
  • Nozzle erosion.  Some nozzles (i.e. simple PVC nozzles) may erode or degrade significantly during the burn.
  • Tank dis-equilibrium.  It may not be reasonable to assume that the gas-phase nitrous cools as rapidly as the liquid nitrous during the burn.

Other Limitations

  • At present Hsim does not allow for:
  • Injector ports that are not identical with each other
  • Multiple fuel-grain ports
  • Non-cylindrical tanks
  • Supported fuels are limited to PVC pipe, polypropylene, PBAN, and acrylic (Plexiglas).

All of these limitations could easily be removed.

Instructions

Hsim is a simple batch program designed to run in a UNIX system environment.  It was developed primarily under Cygwin, but we’ve run it on Linux as well.  We expect that porting Hsim to an arbitrary UNIX system would be trivial.

Hsim is a simple batch program.  It reads an input file specifying the simulation to run and generates an output file with the results of the simulation.

Input File Format

The input file specifies a number of numerical parameters for the simulator.  Here is a sample input file:

 
fuel            PVC
tankheight      28      in
ullageheight    1       in
tankdia         2.049   in
grainlength     12      in
graindiameter   1.900   in
graincore       1.592   in
nozzlethroat    .810    in
nozzleexit      1.364   in
#nozzleratio    2.500
nozcfadj        0.85
cstaradj        0.95
injectordia     0.26    in
injectorcd      0.25
ventdia         0       in
ventcd          0.25
timestep        0.001   sec
#filltemp       272.7   K
#filldrop       0       psi
fillpress       400     psi
drymass         3       kg

Each line has three fields.  The first field is the name of the parameter.  Parameters may be specified in any order.  Parameter names are case sensitive.  The second field is the parameter value.  If the parameter is a physical quantity, then the third field specifies the unit of measure.

The fields are separated by arbitrary amounts of white space.  Blank lines and lines beginning with a ‘#’ are ignored.  In theory anything after ‘#’ on any line is ignored, but there may be bugs with the input parser that prevent proper processing of comments that do not begin at the beginning of the line.

The list of legal units can be found by examining the source file scio.c.

Input Parameters

This table lists the input parameters that may be specified in the input file.

 
Parameter Required? Notes
Fuel
No Must be one of the supported fuels.  The list of known fuels can be found in the file fuel.csv.  Default value is “PVC”
tankheight
Yes Total height of the nitrous tank.  Includes the ullage height.
ullageheight
Yes The length of the portion of the tank that will contain gas when the tank is full.  Typically this is the distance from the top of the tank to the vent hole.
tankdia
Yes Inner diameter of the tank.  Used with the height parameters to compute the tank volume.
grainlength
Yes Length of the fuel grain
graindiameter
Yes The outer diameter of the fuel grain
graincore
Yes The initial diameter of the port through the fuel grain.
nozzlethroat
Yes Diameter of the nozzle’s throat
nozzleexit
No Diameter of the nozzle’s exit
nozzleratio
No Ratio of area of the nozzle exit to area of the nozzle throat.   Exactly one of nozzleexit and nozzleratio must be specified.
nozzlecfadj
Yes A floating point number in the range [0-1].  0 means the nozzle is perfectly terrible and forces the nozzle Cf to a value of 1.0.  An adjustment factor of 1.0 means the nozzle is perfect and leaves the Cf returned by CPROPEP untouched.  Values in the middle adjust the Cf towards 1.0 by some amount.
cstaradj
Yes A floating point number in the range [0-1].  This number is multiplied by the C* returned from CPROPEP.  This number represents the combustion efficiency.
injectordia
Yes The diameter of the injector port(s).
injectorcount
No Number of injector ports. Default value is 1.
injectorcd
Yes The injector port’s discharge coefficient.
injectorcount
No Default value is 1.
ventdia
Yes The vent port’s diameter.  May be set to zero if the tank is not vented.
ventcd
Yes The vent port’s discharge coefficient.
timestep
No Simulator’s time step.  Default value is 0.001 seconds
filltemp
No The temperature of the nitrous supply tank
filldrop
No The pressure drop from the supply tank to the flight tank
fillpress
No The initial pressure in the flight tank.  You must specify either fillpress or both of filltemp and filldrop.
drymass
No The dry mass of the motor, exclusive of the fuel grain.  This parameter is required if the output of the simulator will be used to create a rocksim file.

Output File Format

The output of the simulator is an ascii file full of numbers.  This file is post-processed by the report generator to produce human-readable output.

No documentation of the file format is available, but you can probably figure it out by looking at one of the files.

Command Line Invocation

Hsim is intended to be run from a command line prompt.  Under Windows the easiest way to get such a prompt is to click on the start button, click “run…” and enter “cmd”.  This should give you a dos prompt.  Type cd <dir> where <dir> is the directory containing hsim.

Hsim is intended to be invoked as follows:

 
hsim < sim.input > sim.output
report < sim.output

Theoretically, Hsim needs to run CPROPEP on every iteration as the combustion chamber state is computed, and this must be recomputed on every time step.  Actually invoking CPROPEP on each chamber calculation would make the program run extremely slowly.

In order to speed up operation, Hsim relies on the fact that CPROPEP has only 4 relevant input parameters, the fuel type, the nozzle exit to throat ratio, the chamber pressure, and the oxidizer to fuel ratio.  Two of these (fuel and nozzle ratio) do not change during a run of the simulator.

At the start of a simulation run, Hsim loads in a mesh of CPROPEP computed data points.  For this run’s nozzle ratio and fuel, the mesh provides a number of data points at different O/F ratios and chamber pressures.  Intermediate values between the data points are interpolated.  For a typical 2GHz computer, CPROPEP requires about 2 minutes of compute to create the mesh.  Since typical design problems require multiple simulations using only a small set of fuel/nozzle ratio combinations, the results of this CPROPEP calculation are stored on disk.

Normally hsim will refuse to run if cached CPROPEP results are not available.  Providing hsim with the  “–N exec” command line option allows it to invoke CPROPEP as needed.

The report generator reads the simulator output file and generates a report.  If a –r <filename> option is provided to the report generator it will also create a rocksim engine data file in <filename>.  This file can be used by Rocksim version 8 to simulate a rocket with the simulated hybrid engine.

Installation

Hsim is shipped in source form.  It has been successfully compiled and run under Linux and the Cygwin emulation environment under windows.  Hsim is shipped ready to run on Windows systems.  Running under Linux or other UNIX system will require recompilation.

Windows Installation

Create a new folder (directory) somewhere and place hsim.zix into that folder.   Rename hsim.zix to hsim.zip.  Double-click on hsim.zip file and select “Extract here”.  This will install the program, its binaries and some other stuff into the folder.

NOTE: If you have cygwin installed, delete the copy of cygwin1.dll that came off the zip file and run the program from a cygwin window.  If you do not have cygwin installed then run the simulator from a dos prompt in this directory.

Linux Installation

Follow these simple instructions to build and run hsim:

  1. Extract the tar file into a directory.  It will create two subdirectories, “hybrid” and “lib”.
  2. Change to the “lib” directory and type “make”.  This will create librsim.a.
  3. Change to the hybrid directory and type “make”.  This will create libhybrid.a, hsim, report, and several test programs.

You will also need a Linux version of cpropep.  This should be installed in the cpropep subdirectory.  Be sure to use the propellant.dat file that comes with this distribution, or to adjust the propellant line numbers found in fuel.csv to match the correct line numbers in your propellant.dat file.

Test Runs

The directory hybrid\TEST contains a sample input file, test.input.  The remaining files in the test directory were created using

 
hsim < TEST\test.input > TEST\test.output
report < TEST\test.output > TEST\test.report -r TEST\test.rse

The program as distributed should be able to regenerate these files byte for byte.

This simple test may only work if run from the “hybrid” directory.  Unfortunately there are some path names wired into the linkage between hsim and cpropep.  These paths are defined in hybrid/cpp.h.  The windows version also needs to find the cygwin1.dll file, which may need to be in the current directory.

The program ships with the cached cpropep data used by test.input.  Any changes to fuel or nozzle parameters will require the –N option to create a new cpropep data mesh.